<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		
		<script type="text/javascript">
			//第一题：修改每个th颜色
			
			window.onload=function(){
				var a=document.getElementsByTagName("th");
				for (var i=0;i<a.length;i++) {
					document.getElementsByTagName("th")[i].style.background="red"
				}
				
				
				
			}
			//2.从数据列表开始，奇数行为蓝色，偶数行为红色
			
			window.onload=function(){
				var table=document.getElementsByTagName("table")[0]
				for (var i=0;i<3;i++) {
					var newtr1=document.createElement("tr");
					table.appendChild(newtr1)
				for (var j=0;j<5;j++) {
				var newtd = document.createElement("td");
				newtr1.appendChild(newtd);
				for (var k=0;k<1;k++) {
					var newtext=document.createTextNode("1");
					newtd.appendChild(newtext);
				}
			}
				}
				
				var huoqu=document.getElementsByTagName("tr")
				for (var l=1;l<4;l++) {
				if (l%2==1) {	
					huoqu[l].style.background="blue";
				}else{
					huoqu[l].style.background="red";
				}
				
				}
			
			}
		</script>
	</head>
	<body>
		<table border="1">
				<tr>
					<th class="" >部门名称</th>
					<th class="">部门电话</th>
					<th class="">部门负责人</th>
					<th class="">所属单位</th>
					<th class="">操作</th>
				</tr>
				
		</table>

	</body>
</html>
